package cn.tedu.waimai.mapper;

import cn.tedu.waimai.entity.Orders;
import cn.tedu.waimai.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;


@Mapper
public interface UserMapper {

    //登录注册验证查询
    @Select("select password from user where username=#{username}")
    User selectByUsername(String username);

    //注册成功添加用户
    @Insert("insert into user values(null,#{username},#{password},#{nickname})")
    void insertUser(User user);

    //添加订单
    @Insert("insert into orders values(null,#{order_name},#{order_price},#{phone},#{address})")
    void insertOrders(Orders orders);

    //根据手机号查询订单
    @Select("select * from orders where phone=#{phone}")
    void selectOrdersByPhone(int phone);

    //查询商品列表
    @Select("select * from food group by f_type=#{f_type}")
    void selectFoodList(String type);


}
